<!--
 * @author: sanbao
 * @Date: 2022-08-01 11:22:47
-->
<style lang='scss' scoped>
.loing {
  .el-button {
    width: 100%;
    padding: 20px 0;
  }
  .form {
    margin-bottom: 20px;
  }
}
</style>

<template>
  <div class="loing">
    <el-dialog v-model="list.dialogVisible" :title="list.title" width="20%">
      <el-form :model="form" label-width="120px">
        <template v-for="(item, index) in list.listArray">
          <el-input
            v-if="item.type == 'input'"
            v-model="form[item.model]"
            :placeholder="item.lable"
            class="form"
          />
          <el-button
            v-if="item.type == 'button'"
            type="primary"
            @click="handelbutton(item.action)"
          >
            {{ item.name }}
          </el-button>
        </template>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { ref, reactive, toRefs, computed } from "vue";
export default {
  props: {
    list: Object,
  },
  components: {},
  setup(props, { emit }) {
    const data = reactive({
      dialogVisible: true,
      form: {},
    });
    const handelbutton = (action) => {
      emit("handelbutton", { action, form: data.form });
    };
    return {
      ...toRefs(data),
      handelbutton,
    };
  },
};
</script>
